using System;
using System.Collections.Generic;
using System.Text;

using Justa.Messaging;

namespace Justa.Framework
{
    class Program
    {
        static void Main(string[] args)
        {
            IMessageGateway gateway = MessageGatewayFactory.CreateGateway("sage.messaging.process");
            //gateway.Receive("sage.messaging.receive", OnMessageEvent);

            string response = gateway.Request("yahoo.response", "yahoo sucks", 5000);
            Console.WriteLine("here: " + response);

            //System.Threading.Thread.Sleep(1000 * 20);

            //gateway.StopReceiving("sage.messaging.receive");
            //Console.WriteLine("stopped complete, moving on");

            System.Threading.Thread.Sleep(1000 * 100);
        }


        public static void OnMessageEvent(object sender, MessageEventArgs message)
        {
            message.Message.Formatter = new System.Messaging.XmlMessageFormatter(new String[] { "System.String" });
            Console.WriteLine("Captured message: {0} ", message.Message.Body.ToString());
        }
        
    }
}
